package com.ordertracker.entity;

import com.ordertracker.constant.Sex;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Description of class.
 * Created 1/18/13 2:05 PM
 *
 * @author andrey.rodin@playtech.com
 */

@XmlRootElement
public class Person extends VersionedEntity {

    private static final long serialVersionUID = -4056624843724741823L;
    private String firstName;
    private String lastName;
    private byte old;
    private String contactPhone;
    private Sex gender;

    public Person() {
    }

    public Person(Long id, Long version, String firstName, String lastName, byte old, String contactPhone, Sex gender) {
        setId(id);
        setVersion(version);
        this.firstName = firstName;
        this.lastName = lastName;
        this.old = old;
        this.contactPhone = contactPhone;
        this.gender = gender;
    }

    @XmlElement(nillable = false)
    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    @XmlElement
    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    @XmlElement
    public byte getOld() {
        return old;
    }

    public void setOld(byte old) {
        this.old = old;
    }

    @XmlElement
    public String getContactPhone() {
        return contactPhone;
    }

    public void setContactPhone(String contactPhone) {
        this.contactPhone = contactPhone;
    }

    @XmlElement(nillable = false)
    public Sex getGender() {
        return gender;
    }

    public void setGender(Sex gender) {
        this.gender = gender;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Person)) return false;

        Person person = (Person) o;
        if (!getId().equals(person.getId())) return false;
        if (!getVersion().equals(person.getVersion())) return false;
        if (old != person.old) return false;
        if (contactPhone != null ? !contactPhone.equals(person.contactPhone) : person.contactPhone != null)
            return false;
        if (!firstName.equals(person.firstName)) return false;
        if (gender != person.gender) return false;
        if (lastName != null ? !lastName.equals(person.lastName) : person.lastName != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + firstName.hashCode();
        result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
        result = 31 * result + (int) old;
        result = 31 * result + (contactPhone != null ? contactPhone.hashCode() : 0);
        result = 31 * result + gender.hashCode();
        return result;
    }

    @Override
    public String toString() {
        return "Person{" +
                "firstName='" + firstName + '\'' +
                ", lastName='" + lastName + '\'' +
                ", old=" + old +
                ", contactPhone='" + contactPhone + '\'' +
                ", gender=" + gender +
                ", "+super.toString();
    }
}
